package com.hualan.zhsq.controller.property;

import com.hualan.zhsq.entity.property.UrgencyLevel;
import com.hualan.zhsq.service.property.UrgencyLevelService;
import com.hualan.zhsq.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName UrgencyLevelController
 * @Description 紧急程度controller
 * @Author ZheRan
 * @Date 2025年08月04日 下午8:26
 * @Version 1.0
 */
@RestController
public class UrgencyLevelController {
    @Autowired
    private UrgencyLevelService urgencyLevelService;

    //插入一条数据
    @PostMapping("/urgencyLevel/add")
    public Result add(@RequestParam UrgencyLevel urgencyLevel) {
        return Result.success(urgencyLevelService.add(urgencyLevel));
    }

    //根据id修改一条数据
    @PutMapping("/urgencyLevel/edit")
    public Result edit(@RequestBody UrgencyLevel urgencyLevel) {
        return Result.success(urgencyLevelService.edit(urgencyLevel));
    }

    //根据id删除一条数据
    @DeleteMapping("/urgencyLevel/remove/{id}")
    public Result remove(@PathVariable("id") Integer id) {
        return Result.success(urgencyLevelService.remove(id));
    }

    //批量逻辑删除数据
    @DeleteMapping("/urgencyLevel/removeBatch")
    public Result removeBatch(@RequestParam("ids") Integer[] ids) {
        return Result.success(urgencyLevelService.removeBatch(ids));
    }

    //根据id查询一条数据
    @GetMapping("/urgencyLevel/findById/{id}")
    public Result findById(@PathVariable("id") Integer id) {
        return Result.success(urgencyLevelService.findById(id));
    }

    //查询所有数据
    @GetMapping("/urgencyLevel/findPage")
    public Result findPage() {
        return Result.success(urgencyLevelService.findPage(1, 10, new UrgencyLevel()));
    }
}
